import 'package:flutter_axrjc/datasource/network/api/LightApi.dart';
import 'package:flutter_axrjc/datasource/network/bean/CheckLogBean.dart';
import 'package:get/get.dart';

import 'state.dart';

class CheckLogDetailLogic extends GetxController {
  final CheckLogDetailState state = CheckLogDetailState();
  late CheckLogBean bean;
  @override
  void onInit() {
    super.onInit();
    bean = Get.arguments as CheckLogBean;
    getSingle();
  }

  Future<void> getSingle() async {
    state.logDetailBean.value = await LightApi.getLogDetail(
        fixtureId: "${bean.fixtureId}", recordId: "${bean.recordId}");
    var type = await LightApi.getAllType();
    state.typename.value = type
            .firstWhereOrNull((element) =>
                element.codeValue == state.logDetailBean.value?.fixtureType)
            ?.codeName ??
        '';
  }
}
